<?php
/**
 * 微信公众号菜单
 * User: Acer
 * Date: 2022/7/24
 * Time: 15:22
 */
namespace app\wx\controller;
use app\core\MyController;
use think\Cache;
use think\Log;

class WxMenu extends MyController
{
    protected $noNeedAction = ['*']; // 不需要校验控制器，通道
    // 操作前置
    protected $beforeActionList = ['my_initialize'];
    //菜单
    protected $menu_list = '{
             "button":[
                 {
                      "type":"view",
                      "name":"服务首页",
                      "url":"https://www.e-xingxiao.cn/web/wxLogin"
                  }
                ]
            }';

    // 操作前置方法
    public function my_initialize()
    {

    }

    // 创建菜单
    public function menu_create(){
        header("Content-type: text/html; charset=utf-8");
        $Authorize =  new Authorize();
        $Token = $Authorize->get_token();
        $url = config("gzh_menu_create_url").$Token;
        $res = send_request($url,'POST',$this->menu_list);
        $res = (array)json_decode($res);
        if((int)$res["errcode"] == 0){
            _action_result(200,[],'操作成功！');
        }
        json_err( -210,[$res["errmsg"]]);
    }



}